FROM hub.oepkgs.net/openeuler/openeuler:24.03-lts

ADD ./LibreOffice_24.8.3_Linux_x86-64_rpm.tar.gz /opt/office
ADD ./LibreOffice_24.8.3_Linux_x86-64_rpm_langpack_zh-CN.tar.gz /opt/office

# libreoffice安装到了/opt/libreoffice24.8/
RUN rpm -ivh /opt/office/LibreOffice_24.8.3.2_Linux_x86-64_rpm/RPMS/*.rpm &&\
    rpm -ivh /opt/office/LibreOffice_24.8.3.2_Linux_x86-64_rpm_langpack_zh-CN/RPMS/*.rpm &&\
    rm -rf /opt/office &&\
    dnf install -y libXinerama-devel libXi-devel libXext-devel libX11-devel fontconfig-devel freetype-devel nss-softokn nspr dbus-libs cairo-devel libxslt-devel pcre2-devel libffi-devel gpgme-devel krb5-devel util-linux selinux-policy-devel libxml2-devel libcurl-devel rasqal-devel gobject-introspection-devel glib2-devel cups java-1.8.0-openjdk net-tools unzip glibc-langpack-zh glibc-locale-source &&\
    dnf clean all

# 生成 zh_CN.UTF-8 locale
RUN localedef -i zh_CN -f UTF-8 zh_CN.UTF-8
# 中文字体
ADD ./SourceHanSerifCN.zip  /usr/share/fonts/
RUN unzip /usr/share/fonts/SourceHanSerifCN.zip -d /usr/share/fonts/ && \
    rm /usr/share/fonts/SourceHanSerifCN.zip &&\
    fc-cache -fv &&\
    ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
    echo "Asia/Shanghai" > /etc/timezone

# 设置环境变量
ENV LC_ALL="zh_CN.UTF-8"
ENV LANG="zh_CN.UTF-8"

EXPOSE 8100
# 启动 LibreOffice 的 headless 模式
CMD nohup /opt/libreoffice24.8/program/soffice --headless --accept="socket,host=0.0.0.0,port=8100;urp;" --nofirststartwizard &